<template>
	<view @mousedown.stop="touchStart" @mousemove.stop="touchMove"  @mouseup.stop="touchEnd" class=" height40px posifi top0 zindex200  wacl">
		<view class="pg15-30">
			<view class="flex-ju-b size28 ">
				<view  style="min-width:260rpx;">
					<view @click.stop="openDevTools" v-if="type=='home'" class="flex-a-i">
						<image mode="widthFix" class="image width60 mr15"  :src="IMGURL+config.pcLogoFilePath"></image>
						{{config.pcName}}
					</view>
					<template v-if="isWhite">
						<view v-if="type=='back'" class="colorfff" @click.stop="back()"><uni-icons color="#fff" type="back"></uni-icons> 返回</view>
					</template>
					<template v-else>
						<view v-if="type=='back'" @click.stop="back()"><uni-icons type="back"></uni-icons> 返回</view>
					</template>
				</view>
				<view></view>
				<view :style="{color:isWhite?'#fff':''}">
					{{title}}
				</view>
				<view></view>
				<!-- <view class="flex-a-i color333 posire zindex300">
					<view  v-if="type=='home'" @click.stop="onDownload" class="flex-a-i mr50">
						<image  mode="widthFix" class="image width50" src="/static/img/xiazai.png"></image>
						下载中心
					</view>
					<view  v-if="type=='login'||type=='home'" @click.stop="onSetUP" class="flex-a-i mr50">
						<image mode="widthFix" class="image width50" src="/static/img/shezhi.png"></image>
						设置
					</view>
					<template v-if="isWhite">
						<view @click.stop="onMin" class="hovers flex-ju-c wh60-60 mr40">
							<image mode="widthFix" class="image width50 " src="/static/img/bheng.png"></image>
						</view>
						<view @click.stop="onMax" class="hovers flex-ju-c wh60-60 mr40">
							<image  v-if="windowMax" mode="widthFix"  class="image width50  " src="/static/min.png"></image>
							<image v-else mode="widthFix" class="image width50  " src="/static/min.png"></image>
						</view>
						<view @click.stop="onClose" class="hover flex-ju-c wh60-60 mr10">
							<image mode="widthFix" class="image width50" src="/static/img/bbi.png"></image>
						</view>
					</template>
					<template v-else>
						<view @click.stop="onMin" class="hovers flex-ju-c wh60-60 mr40">
							<image mode="widthFix" class="image width50 " src="/static/img/heng.png"></image>
						</view>
						<view v-if="type!='login'" @click.stop="onMax" class="hovers flex-ju-c wh60-60 mr40">
							<image  v-if="windowMax" mode="widthFix"  class="image width50  " src="/static/img/black.png"></image>
							<image v-else mode="widthFix" class="image width50  " src="/static/img/da.png"></image>
						</view>
						<view @click.stop="onClose" class="hover flex-ju-c wh60-60">
							<image mode="widthFix" class="image width50" src="/static/img/bi.png"></image>
						</view>
					</template>
				</view> -->
			</view>
		</view>
		<tishi ref="upLogin" isclen="1" bgcolor="#fc474c" title="您确定要退出登录吗？"></tishi>
		<!-- 手机下载配置 -->
		<phone-config ref="upDownload"></phone-config>
	</view>
	
	<view class="flex-ju-b posifi top0 zindex200 width330px right20 flex-row">
		<view class="flex-a-i   color333 posire zindex300">
			<view  v-if="type=='home'||type=='login'" @click.stop="onDownload" class="flex-a-i mr50">
				<image  mode="widthFix" class="image width50" src="/static/img/xiazai.png"></image>
				下载中心
			</view>
			<view  v-if="type=='login'||type=='home'" @click.stop="onSetUP" class="flex-a-i mr50">
				<image mode="widthFix" class="image width50" src="/static/img/shezhi.png"></image>
				设置
			</view>
			<template v-if="isWhite">
				<view @click.stop="onMin" class="hovers flex-ju-c wh60-60 mr40">
					<image mode="widthFix" class="image width50 " src="/static/img/bheng.png"></image>
				</view>
				<view @click.stop="onMax" class="hovers flex-ju-c wh60-60 mr40">
					<image  v-if="windowMax" mode="widthFix"  class="image width50  " src="/static/min.png"></image>
					<image v-else mode="widthFix" class="image width50  " src="/static/min.png"></image>
				</view>
				<view @click.stop="onClose" class="hover flex-ju-c wh60-60 mr10">
					<image mode="widthFix" class="image width50" src="/static/img/bbi.png"></image>
				</view>
			</template>
			<template v-else>
				<view @click.stop="onMin" class="hovers flex-ju-c wh60-60 mr40">
					<image mode="widthFix" class="image width50 " src="/static/img/heng.png"></image>
				</view>
				<view v-if="type!='login'" @click.stop="onMax" class="hovers flex-ju-c wh60-60 mr40">
					<image  v-if="windowMax" mode="widthFix"  class="image width50  " src="/static/img/black.png"></image>
					<image v-else mode="widthFix" class="image width50  " src="/static/img/da.png"></image>
				</view>
				<view @click.stop="onClose" class="hover flex-ju-c wh60-60">
					<image mode="widthFix" class="image width50" src="/static/img/bi.png"></image>
				</view>
			</template>
		</view>
	</view>
	
	
</template>

<script>
	export default {
		name: "navigation-bar",
		props:['screen','title','isWhite','type'],
		data() {
			return {
				isDragging:false,
				windowMax:false,
				config:""
			};
		},
		watch:{
			screen(){
				this.windowMax = windowMax
			}
		},
		created() {
			this.windowMax = windowMax
			this.config = uni.getStorageSync('config_data')
		},		
		methods:{
			openDevTools(){
				if(window.flutter){
					 flutter.call('openDevTools', {}, (result, error) => {})
				}
			},
			touchStart(){
				this.isDragging = true
			},
			touchEnd(){
				this.isDragging = false
			},
			touchMove(e) {
			  if (!this.isDragging) return
			  if(window.flutter){
				  flutter.call('startDragging', {}, (result, error) => {})
			  }
			},
			onSetUP(){
				this.$emit('onSetUP')
			},
			onDownload(){
				this.$emit('onDownload')
				this.$refs.upDownload.open()
			},
			onClose(){
				
				if(this.type=='login'){
					flutter.call('close', {}, (result, error) => {
					})
				}else{
					uni.$emit('exitclose')
					this.$refs.upLogin.show()
				}
			},
			onMax(){
				let that = this
				if(this.windowMax){
					flutter.call('unMaximize', {}, (result, error) => {
						that.windowMax=false
						windowMax = false
					});
				}else{
					flutter.call('maximize', {}, (result, error) => {
						that.windowMax=true
						windowMax = true
					});
				}
			},
			onMin(){
				flutter.call('minimize', {}, (result, error) => {
				});
			},
		}
	}
</script>

<style>
	.wacl{
		width:calc(100vw - 340px);
	}
.hover:hover{
	background: #e81123;
}
.hovers:hover{
	background: #becce3;
}
.zindex999{
	z-index: 999 !important;
}
</style>